<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@include file="../common/jspcommon.jsp"%>

<script type="text/javascript">
$(function(){
	$("#pager").pager({ pagenumber: ${pageModel.currentPage}, 
						pagecount: ${pageModel.totalPage},
						buttonClickCallback: function(page){
							$("#message_content").load("messageFriend.htm?page="+page);
						} 
	});
	
	//家的消息数量
	$("#my_family_message_no_read").text('${messageNoRead}');
});

	function agreeFriend(msgId,familyId){
		$.post("agreeFriend.htm",{msgId:msgId,familyId:familyId},function(data){
			if(data=='success'){
				$("#h_invitefriends_text_"+msgId).empty();
				$("#h_invitefriends_text_"+msgId).hide();
				$("#h_invitefriends_agree_"+msgId).show();
			}
		});
	}
	//忽略好友
	function ignoreFriend(msgId,familyId){
		$.post("ignoreFriend.htm",{msgId:msgId,familyId:familyId},function(data){
			if(data=='success'){
				$("#h_invitefriends_text_"+msgId).empty();
				$("#h_invitefriends_text_"+msgId).hide();
				$("#h_invitefriends_ignore_"+msgId).show();
			}
		});
	}
	
	function messageInner(){
		$("#content_detail").load("messageInner.htm");
	}
	
</script>
<div class="h_main2">
	<div class="h_data">
		<h2>
			信息
		</h2>
		<div class="h_newNews">
			<ul>
				<!-- 
						<li id="newNews1" onclick="setTab('newNews',1,3)"
							class="h_newNewsHover">
							<a>系统信息</a>
						</li>
						 -->
				<li id="newNews2" class="h_newNewsHover">
					<a>邻居邀请(${messageFriendNoRead})</a>
				</li>
				<li id="newNews3" onclick="messageInner();">
					<a>站内信息(${messageInnerNoRead})</a>
				</li>
				<div class="clear"></div>
			</ul>
			<div class="clear"></div>
		</div>
		<div id="message_content">
			<div class="h_newNews_box">
				<c:choose>
					<c:when test="${pageModel.totalPage < 1}">
						<div style="margin-left: 10px; margin-top: 20px;">
							您目前没有邻居邀请消息
						</div>


					</c:when>
					<c:otherwise>
						<div class="h_newNews_text" id="con_newNews_1"
							style="display: block;">
							<div class="h_invitefriends_list pt10">
								<ul>
									<c:forEach items="${pageModel.list}" var="msgExt">
										<li>
											<span><fmt:formatDate value="${msgExt.gmtModified}"
													pattern="yyyy-MM-dd HH:mm" /> </span>
											<a href="#" title="进入他的家"><img width="58" height="58"
													src="${msgExt.familyAvatar}" alt="头像" /> </a>
											<em>${msgExt.familyNickname}</em>
											<p class="h_invitefriends_name">
												<a href="javascript:void(0);" onclick="seeOtherFamily('${msgExt.familyId}')">${msgExt.sendUsername}</a>申请与你成为邻居!
											</p>
											<p class="h_invitefriends_text">
												<span id="h_invitefriends_text_${msgExt.identifier}"><a
													href="javascript:void(0);"
													onclick="agreeFriend('${msgExt.identifier}','${msgExt.familyId}');">同意</a><em>|</em><a
													href="javascript:void(0);"
													onclick="ignoreFriend('${msgExt.identifier}','${msgExt.familyId}');">忽略该请求</a>
												</span>
												<c:out value="${msgExt.content}" />
											</p>
											<div>
												<div class="h_invitefriends_agree" style="display: none;"
													id="h_invitefriends_agree_${msgExt.identifier}">
													恭喜你已与对方成为邻居
												</div>
												<div class="h_invitefriends_agree" style="display: none;"
													id="h_invitefriends_ignore_${msgExt.identifier}">
													你已忽略对方的请求
												</div>
												<!-- 
										<p class="h_invitefriends_group">
											<a href="#">设置好友分组</a>
										</p>
										 -->
											</div>
											<div class="clear"></div>
										</li>
									</c:forEach>
								</ul>
								<div class="clear"></div>
								<div class="h_page" id="pager"></div>
							</div>
							<div class="h_newNews_text" id="con_newNews_2"></div>
							<div class="h_newNews_text" id="con_newNews_3"></div>
							<div class="clear"></div>
						</div>
					</c:otherwise>
				</c:choose>

				<div class="clear"></div>
			</div>
		</div>
	</div>
</div>

